Telegram Group & Telegram Channel
Forwarded from Python/ django
🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl



tg-me.com/python_testit/1160
Create:
Last Update:

🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl

BY Python tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_testit/1160

View MORE
Open in Telegram


Python tests Telegram | DID YOU KNOW?

Date: |

Telegram announces Search Filters

With the help of the Search Filters option, users can now filter search results by type. They can do that by using the new tabs: Media, Links, Files and others. Searches can be done based on the particular time period like by typing in the date or even β€œYesterday”. If users type in the name of a person, group, channel or bot, an extra filter will be applied to the searches.

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

Python tests from ru


Telegram Python tests
FROM USA